package com.gitee.minimalismstyle.fresh.simple.sql.impl

import com.gitee.minimalismstyle.fresh.simple.api.model.SimpleFormField
import com.gitee.minimalismstyle.fresh.simple.sql.Condition
import org.springframework.stereotype.Component

@Component
class BetweenCondition: Condition {
    override fun add(sql: StringBuffer, simpleFormField: SimpleFormField) {
        sql.append("""
            --@if(isNotEmptyAny(${simpleFormField.code})){
                --@if(isNotEmptyAny(${simpleFormField.code}[0])){
                and ${simpleFormField.column} > #{${simpleFormField.code}[0]}
                --@}
                --@if(isNotEmptyAny(${simpleFormField.code}[1])){
                and ${simpleFormField.column} < #{${simpleFormField.code}[1]}
                 --@}
            --@}
        """)
    }
}